package com.cskaoyan.controller;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.System;
import com.cskaoyan.bean.SystemExample;
import com.cskaoyan.bean.config.ExpressConfig;
import com.cskaoyan.bean.config.MallConfig;
import com.cskaoyan.bean.config.OrderConfig;
import com.cskaoyan.bean.config.WxConfig;
import com.cskaoyan.service.AdminConfigService;
import com.sun.javafx.collections.MappingChange;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @author: heliming
 * @date: 2021/6/5
 * @description:
 */
@RestController
@RequestMapping("admin/config")
public class AdminMallConfigController {

    @Autowired
    AdminConfigService adminConfigService;

    @GetMapping("mall")
    public BaseRespVo mall() {
        MallConfig mallConfig = adminConfigService.selectMall();
        return BaseRespVo.ok(mallConfig);
    }

    @PostMapping("mall")
    public BaseRespVo mall(@RequestBody MallConfig mallConfig) {

        adminConfigService.updateMall(mallConfig);
        return BaseRespVo.ok();
    }

    @GetMapping("express")
    public BaseRespVo express() {
        ExpressConfig expressConfig = adminConfigService.selectExpress();
        return BaseRespVo.ok(expressConfig);
    }

    @PostMapping("express")
    public BaseRespVo express(@RequestBody ExpressConfig expressConfig){
        adminConfigService.updateExpress(expressConfig);
        return BaseRespVo.ok();
    }

    @GetMapping("order")
    public BaseRespVo order(){
        OrderConfig orderConfig = adminConfigService.selectOrder();
        return BaseRespVo.ok(orderConfig);
    }

    @PostMapping("order")
    public BaseRespVo order(@RequestBody OrderConfig orderConfig) {
        adminConfigService.updateOrder(orderConfig);
        return BaseRespVo.ok();
    }

    @GetMapping("wx")
    public BaseRespVo wx() {
        WxConfig wxConfig = adminConfigService.selectWx();
        return BaseRespVo.ok(wxConfig);
    }

    @PostMapping("wx")
    public BaseRespVo wx(@RequestBody WxConfig wxConfig) {
        adminConfigService.updateWx(wxConfig);
        return BaseRespVo.ok();
    }


}
